import { execSync } from 'child_process';
import { ExecutionMode } from './execution-mode';

export enum Platform {
  WINDOWS = 'win32',
  MACOS = 'darwin',
  LINUX = 'linux'
}

export function getCurrentPlatform(): Platform {
  return process.platform as Platform;
}

export function isExeFile(path: string): boolean {
  if (getCurrentPlatform() === Platform.WINDOWS) {
    return path.endsWith('.exe');
  }
  return false;
}

export function ensureExecutionPermission(path: string): void {
  if (getCurrentPlatform() !== Platform.WINDOWS) {
    try {
      execSync(`chmod +x ${path}`);
    } catch (err) {
      console.warn(`Failed to set executable permission: ${err}`);
    }
  }
}